package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.OverflowList;
import com.atguigu.jxc.service.OverFlowListGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @description 商品报溢Controller层
 */
@RestController
@RequestMapping("/overflowListGoods")
public class OverFlowListGoodsController {

    @Autowired
    OverFlowListGoodsService overFlowListGoodsService;

    /*新增报溢单
    * 请求URL：http://localhost:8080/overflowListGoods/save?overflowNumber=BY1605767033015（报溢单号）
        请求参数：OverflowList overflowList, String overflowListGoodsStr
        请求方式：POST
        返回值类型：JSON
        返回值：ServiceVO
    * */
    @PostMapping("/save")
    @ResponseBody
    public ServiceVO saveOverflowListGoods(OverflowList overflowList, String overflowListGoodsStr){
        return overFlowListGoodsService.saveOverflowListGoods(overflowList,overflowListGoodsStr);
    }

    /*报溢单查询
    *请求URL：http://localhost:8080/overflowListGoods/list
    请求参数：String  sTime（开始时间）, String  eTime（结束时间）
    请求方式：POST
    返回值类型：JSON
    返回值：Map<String,Object>
    * */
    @PostMapping("/list")
    public Map<String,Object> getOverflowList(String  sTime, String  eTime){
        return overFlowListGoodsService.getOverflowList(sTime,eTime);
    }

    /*报溢单商品信息
    * 请求URL：http://localhost:8080/overflowListGoods/goodsList
    请求参数：Integer overflowListId
    请求方式：POST
    返回值类型：JSON
    返回值：Map<String,Object>
    * */
    @PostMapping("/goodsList")
    @ResponseBody
    public Map<String,Object> getOverflowGoodsList(Integer overflowListId){
        return overFlowListGoodsService.getOverflowGoodsList(overflowListId);
    }
}
